package com.qumitech.visualnovel.controller.rest;

import com.alibaba.fastjson.JSONArray;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.model.common.BaseResponse;
import com.qumitech.visualnovel.pubdef.dto.group.GroupDetailAdminDTO;
import com.qumitech.visualnovel.pubdef.dto.group.GroupDetailAdminQueryDTO;
import com.qumitech.visualnovel.service.group.GroupService;
import com.google.common.collect.ImmutableMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @Author :  ZhChNing
 * @Descriptiom :
 * @Date Created in 2019/9/12 18:18
 */
@RestController
@RequestMapping(value = "/api/group")
public class GroupAdminController {
    @Autowired
    private GroupService groupService;

    @GetMapping(value = "/option")
    public BaseRsp getGroupOption() {
        return groupService.listGroupIdItem();
    }


    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public BaseRsp GroupList(GroupDetailAdminQueryDTO queryDTO) {
        queryDTO.setUid(queryDTO.getTargetId());
        return new BaseRsp(ResultEnum.SUCCESS, groupService.listGroupDetailAdminDTO(queryDTO));
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public BaseRsp addGroup(@RequestBody GroupDetailAdminDTO req) {
        groupService.addGroupDetailAdminDTO(req);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

    @RequestMapping(value = "/rm/{id}", method = RequestMethod.DELETE)
    public BaseRsp rmGroupDetail(@PathVariable("id") Long id) {
        groupService.rmGroupDetailAdminDTO(id);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

    @RequestMapping(value = "/reset/{id}", method = RequestMethod.POST)
    public BaseRsp resetGroupDetail(@PathVariable("id") Long id) {
        groupService.resetGroupDetailAdminDTO(id);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

}
